package com.xb.controller;

import com.xb.bean.TokenBean;
import com.xb.bean.UserBean;
import com.xb.service.UserService;
import com.xb.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("pro")
public class LoginController {

    @Autowired
    private UserService userService;

    @PostMapping("login")
    public ResultUtil<TokenBean> login(@RequestBody UserBean userBean) {
        TokenBean tokenBean = userService.login(userBean);
        return ResultUtil.success(tokenBean, "登录成功");
    }

    @PostMapping("getUserInfo")
    public ResultUtil<UserBean> getUserInfo(@RequestHeader String authorization) {
        UserBean userBean = userService.getUserInfo(authorization);
        return ResultUtil.success(userBean, "获取用户信息成功");
    }

}
